package com.vincent.dao;

import com.vincent.model.Role;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Vincent on 2014/12/29.
 */
@Repository("roleDao")
public class RoleDao {
    @Resource
    private RoleMapper roleMapper;

    public List<Role> selectAll(){
        return roleMapper.selectAll();
    }

    public Role selectByName(String name){
        return roleMapper.selectByName(name);
    }

    public Role selectById(Integer id){
        return roleMapper.selectByPrimaryKey(id);
    }

    public void saveRole(Role role){
        roleMapper.insertSelective(role);
    }

    public void updateRole(Role role){
        roleMapper.updateByPrimaryKeySelective(role);
    }

    public void deleteRole(Integer id){
        roleMapper.deleteByPrimaryKey(id);
    }
}
